﻿namespace ModernChannel.Data.DBConfig
{
    using Common.Data.Extensions;
    using ModernChannel.Configuration;
    using ModernChannel.Model.Model;
    using System.Data.Entity.ModelConfiguration;

    public class ModernChannelConfiguration : DBConfig<ModernChannels>
    {
        public ModernChannelConfiguration()
            : base(SystemConfiguration.Schema, SystemConfiguration.NamingType, SystemConfiguration.TABLE_PREFIX)
        {
            HasKey(k => new { k.SerialNo, k.Model, k.ShopCode });
            Property(c => c.ShopCode).HasMaxLength(10).IsRequired();
            Property(c => c.SerialNo).HasMaxLength(20).IsRequired();
            Property(c => c.Model).HasMaxLength(50).IsRequired();
            Property(c => c.IncentiveCfmFlag).HasMaxLength(10).IsRequired();
            Property(c => c.CreateDate).IsRequired();

            ////relationship  
            HasRequired(s => s.ShopInf).WithMany(c => c.ModernChannels).HasForeignKey(k => k.ShopCode).WillCascadeOnDelete(false);
            //HasOptional(s => s.ModelCat).WithMany(c => c.ModernChannels).HasForeignKey(k => k.Model).WillCascadeOnDelete(false);
            //HasOptional(s=>s.Model).WithMany(c=>c.)
            //HasRequired(t => t.Group).WithMany(c => c.Accounts).HasForeignKey(t => new { t.ApplicationKey, t.GroupId }).WillCascadeOnDelete(false);
        }
    }
}
